<template>
  <div>
    <div id="container" style="width: 100%; height: 90vh"></div>
  </div>
</template>

<script>
export default {
  mounted() {
    // 创建地图实例
    var map = new AMap.Map("container", {
      zoom: 13,
      center: [106.587152,29.576674],
    });
    var marker = new AMap.Marker({
      position: new AMap.LngLat(106.587152,29.576674),
      offset: new AMap.Pixel(-10, -10),
      icon: "//vdata.amap.com/icons/b18/1/2.png", // 添加 Icon 图标 URL
      title: "重庆大学",
    });

    map.add(marker);

    var map = new AMap.Map("container");
    var clickHandler = function (e) {
      console.log(
        "您在[ " +
        e.lnglat.getLng() +
        "," +
        e.lnglat.getLat() +
        " ]的位置点击了地图！"
      );
    };

    // 绑定事件
    map.on("click", clickHandler);
  },
};
</script>

<style>
</style>
